#include <iostream>
using namespace std;


// 现在先来回顾一下 动态规划：
/*
*   先确定动态转移方程
* 处理细节问题

*/
using ll = long long;
const int N = 1e5 + 10;
ll a[N];
ll dp[N];
int main()
{   
    int n; cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 2; i <= n; i++)
    {
        dp[i] = min(dp[i - 1] + a[i - 1], dp[i - 2] + a[i - 2]);
    }
    if (n < 2){
        cout << a[n - 1] << endl;
        return 0;
    }
    cout << dp[n] << endl;
    return 0;
}